home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / source / src / arith / Itodouble.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  764 b   |  43 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  Itodouble.c
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15.  
  16. #include <LEDA/impl/iint.h>
  17. #include <LEDA/impl/iloc.h>
  18.  
  19.  
  20. /* S. Naeher   (Feb. 1994) */
  21.  
  22.  
  23. double Itodouble (a)
  24.     const Integer * a;
  25. { register double d=0.0;
  26.   register int i;
  27.  
  28.   for (i=a->length-1; i>=0; i--)
  29.   { unsigned long w = a->vec[i];
  30.     unsigned long b;
  31.     for(b = 1<<(LOGPLACE-1); b != 0; b>>=1)
  32.     { d *= 2.0;
  33.       if (w & b) d += 1.0;
  34.      }
  35.    }
  36.   if (a->sign==PLUS)
  37.      return(d);
  38.   else
  39.      return(-d);
  40. }
  41.  
  42.